#pragma once
#include <iostream>
#include "BTree.h"

template <class T,size_t M = 1024>
class BTreeSet
{
	struct SetKofT
	{
		const T& operator()(const T& date)
		{
			return date;
		}
	};
	typedef BTree::BT<T, SetKofT, M> BTNode;
	typedef typename BTNode::iterator iterator;
public:
	iterator begin()
	{
		return _bt.begin();
	}
	std::pair<T, bool> Find(const T& date)
	{
		//std::pair<std::pair<BN, size_t>,bool>
		//std::pair<T, std::shared_ptr<BNode>>
		auto it = _bt.Find(date);
		bool sig = false;
		auto bn = it.first.first;
		size_t pos = it.first.second;
		if (it.second && bn->_exist[pos])sig = true;
		return { bn->_BN[pos].first,sig };
	}
	bool insert(const T& date)
	{
		return _bt.insert(date);
	}
	void Print()
	{
		_bt.Print();
	}
	bool erase(const T& date)
	{
		return _bt.erase(date);
	}

private:
	BTNode _bt;
};